CC            = gcc
CXX           = g++
DEFINES       = 
CFLAGS        =  -O2 -Wall -W -Wextra $(DEFINES)
CXXFLAGS      =  -O2 -Wall -W -Wextra -pedantic  $(DEFINES)
INCPATH       = -I.
LINK          = g++
LFLAGS        =  -Wl,-O1
LIBS          = $(SUBLIBS)  -L/usr/lib -lm
COPY          = cp -f
COPY_FILE     = $(COPY)
COPY_DIR      = $(COPY) -r
DEL_FILE      = rm -f
SYMLINK       = ln -f -s
DEL_DIR       = rmdir
MOVE          = mv -f
CHK_DIR_EXISTS= test -d
MKDIR         = mkdir -p

####### Output directory

TESTFILE = Classe_point.cpp

OBJECTS_DIR   = ./

####### Files

OBJECTSG       = Classe_point.o \
		Classe_graphe.o \
		main_Graphe.o

OBJECTSP       = Classe_point.o \
	        main_Point.o

OBJECTREC	= Classe_point.o \
		Classe_graphe.o \
		Rectangle.o \
 		main_Rectangle.o

OBJECTCARRE	= Classe_point.o \
		Classe_graphe.o \
		Rectangle.o \
		Carre.o \
		main_Carre.o

DESTDIR       = 
TARGETG        = graphe.exe
TARGETP        = point.exe
TARGETREC	= rectangle.exe
TARGETCARRE	= carre.exe

####### Build rules

all: $(TARGETREC) $(TARGETCARRE) $(TARGETG) $(TARGETP)

$(TARGETG):  $(OBJECTSG)  
	$(LINK) $(LFLAGS) -o $(TARGETG) $(OBJECTSG) $(OBJCOMP) $(LIBS)

$(TARGETP):  $(OBJECTSP)  
	$(LINK) $(LFLAGS) -o $(TARGETP) $(OBJECTSP) $(OBJCOMP) $(LIBS)

$(TARGETREC): $(OBJECTREC)  
	$(LINK) $(LFLAGS) -o $(TARGETREC) $(OBJECTREC) $(OBJCOMP) $(LIBS)

$(TARGETCARRE): $(OBJECTCARRE)  
	$(LINK) $(LFLAGS) -o $(TARGETCARRE) $(OBJECTCARRE) $(OBJCOMP) $(LIBS)


clean: 
	-$(DEL_FILE) $(OBJECTSG)
	-$(DEL_FILE) $(OBJECTSP)
	-$(DEL_FILE) $(OBJECTREC)
	-$(DEL_FILE) $(OBJECTCARRE)
	-$(DEL_FILE) *~ core *.core


####### Sub-libraries

distclean: clean
	-$(DEL_FILE) $(TARGETG) $(TARGETP) $(TARGETCARRE) $(TARGETREC) 



####### Compile
Classe_point.o: $(TESTFILE) Classe_point.h
	$(CXX) -c $(CXXFLAGS) $(INCPATH) -o Classe_point.o Classe_point.cpp

Classe_graphe.o: Classe_graphe.cpp Classe_graphe.h
	$(CXX) -c $(CXXFLAGS) $(INCPATH) -o Classe_graphe.o Classe_graphe.cpp

Rectangle.o: Rectangle.cpp Rectangle.h
	$(CXX) -c $(CXXFLAGS) $(INCPATH) -o Rectangle.o Rectangle.cpp

Carre.o: Carre.cpp Carre.h
	$(CXX) -c $(CXXFLAGS) $(INCPATH) -o Carre.o Carre.cpp



main_Graphe.o: main_Graphe.cpp Classe_graphe.h Classe_point.h
	$(CXX) -c $(CXXFLAGS) $(INCPATH) -o main_Graphe.o main_Graphe.cpp

main_Point.o: main_Point.cpp Classe_point.h
	$(CXX) -c $(CXXFLAGS) $(INCPATH) -o main_Point.o main_Point.cpp

main_Rectangle.o: main_Rectangle.cpp Rectangle.h Classe_graphe.h Classe_point.h
	$(CXX) -c $(CXXFLAGS) $(INCPATH) -o main_Rectangle.o main_Rectangle.cpp

main_Carre.o: main_Carre.cpp Carre.h Rectangle.h Classe_graphe.h Classe_point.h
	$(CXX) -c $(CXXFLAGS) $(INCPATH) -o main_Carre.o main_Carre.cpp

